<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            Set数据结构
                Set是构造函数
                内部数据不重复
         */

        const s1 = new Set([1, 2]);
        console.log(s1.size); //2

        const s2 = new Set([1, 2, 1, 2]);
        console.log(s2.size); //2   
        console.log([...s2]); //数组去重

        const s3 = new Set();
        s3.add('a');
        s3.add("g");
        s3.add(123);

        s3.forEach(val => {
            console.log(val);
        })

        console.log(s3);
        console.log(s3.delete('a'));
        console.log(s3);

        console.log(s3.has(123));

        s3.clear();
        console.log(s3);
    </script>
</body>

</html>